Dr. Wayne Stewart

Dr. Wayne Stewart

1 My Video

2 Introduction

Here you should introduce the data and the problem you wish to solve. Use your own subheadings. Fill with informative sentences and pictures and links. You may inclucde sub-sub headings. You can cite from your bibliography (see Millar 2011 and Crawley (2012))

The data was collected here:

2.1 What are the variables?

data(mtcars)

library(DT)
## Warning: package 'DT' was built under R version 3.5.1
datatable(
  mtcars,filter = 'top', options = list(
  pageLength = 5, autoWidth = TRUE, editable = TRUE, dom = 'Bfrtip',
    buttons = c('copy', 'csv', 'excel', 'pdf', 'print')),
caption = htmltools::tags$caption(
    style = 'caption-side: bottom; text-align: center;',
    'Table 2: ', htmltools::em('This is a simple caption for the table.')
  )
) %>%
  formatStyle('mpg',  color = 'red', backgroundColor = 'orange', fontWeight = 'bold')
library(crosstalk)
## Warning: package 'crosstalk' was built under R version 3.5.1
library(leaflet)
library(DT)

# Wrap data frame in SharedData
sd <- SharedData$new(quakes[sample(nrow(quakes), 100),])

# Create a filter input
filter_slider("mag", "Magnitude", sd, column=~mag, step=0.1, width=250)
# Use SharedData like a dataframe with Crosstalk-enabled widgets
bscols(
  leaflet(sd) %>% addTiles() %>% addMarkers(),
  datatable(sd, extensions="Scroller", style="bootstrap", class="compact", width="100%",
    options=list(deferRender=TRUE, scrollY=300, scroller=TRUE))
)
## Assuming "long" and "lat" are longitude and latitude, respectively
#devtools::install_github("jcheng5/d3scatter")

library(d3scatter)

shared_mtcars <- SharedData$new(mtcars)
bscols(widths = c(3,NA,NA),
  list(
    filter_checkbox("cyl", "Cylinders", shared_mtcars, ~cyl, inline = TRUE),
    filter_slider("hp", "Horsepower", shared_mtcars, ~hp, width = "100%"),
    filter_select("auto", "Automatic", shared_mtcars, ~ifelse(am == 0, "Yes", "No"))
  ),
  d3scatter(shared_mtcars, ~wt, ~mpg, ~factor(cyl), width="100%", height=250),
  d3scatter(shared_mtcars, ~hp, ~qsec, ~factor(cyl), width="100%", height=250)
)

2.1.1 Sub sub headings can be useful

2.1.2 Plot data

library(ggplot2)
## Warning: package 'ggplot2' was built under R version 3.5.1
g = ggplot(mtcars, aes(x = disp, y = mpg, color = cyl)) + geom_point()
g = g + geom_smooth(method = "loess")
g
Graph of data with loess smoother

Graph of data with loess smoother

2.2 How were the data collected?

2.3 What is the story behind the data?

2.4 Why was it gathered?

2.5 What is your interest in the data?

2.5.1 Include pictures ![](jpeg)

2.6 What problem do you wish to solve?

3 Theory needed to carry out SLR

3.1 Main result 1

3.2 Main result 2

3.3 Main result 3 etc

4 Validity with mathematical expressions

The following function was taken from https://rpubs.com/therimalaya/43190

4.1 Checks on validity

4.1.1 Straight trend line

4.1.1.1 Use trendscatter

4.1.2 Errors distributed Normally

\[\epsilon_i \sim N(0,\sigma^2)\]

4.1.2.1 Shapiro-wilk

4.1.3 Constant variance

4.1.3.1 Residual vs fitted values

4.1.3.2 trendscatter on Residual Vs Fitted

4.1.4 Zero mean value of \(\epsilon\)

4.1.5 Independence of data

5 Model selection if you compared models

5.1 Use adjusted \(R^2\)

\[R_{adj}^2 =\]

6 Analysis of the data

6.1 Make sure you include many great plots

6.2 Add the trend to the data

6.3 Summary lm object

6.3.1 Interpretation of all tests

6.3.2 Interpretation of multiple R squared

6.3.3 Interpretation of all point estimates

6.4 Calculate cis for \(\beta\) parameter estimates

6.4.1 Use of predict()

6.4.2 Use of ciReg()

6.4.3 Check on outliers using cooks plots

Remember to interpret this plot and all other plots

7 Conclusion

7.1 Answer your research question

7.2 Suggest ways to improve model or experiment

References

Crawley, Michael J. 2012. “Regression.” In The R Book, 449–97. Chichester, UK: John Wiley & Sons, Ltd.

Millar, Russell B. 2011. “Latent Variable Models.” In Statistics in Practice, 202–32. Chichester, UK: John Wiley & Sons, Ltd.